package com.cuit.jifver.weibo.utils;

import android.app.Activity;
import android.app.AlertDialog;
import android.app.AlertDialog.Builder;
import android.content.Context;
import android.content.DialogInterface;
import android.content.DialogInterface.OnClickListener;
import android.widget.Toast;



public class DialogUtil {

	public static void OneButtonShowMessageDialog(final Context context,final String message)
	{
		OneButtonShowMessageDialog(context, message, 0);
	}
	
	public static void OneButtonShowMessageDialog(final Context context,final String message,final int action) 
	{
		Context con = context;
		if (message == null || message.equals("")) {
			return;
		}
		AlertDialog.Builder dialog = new Builder(con);
		dialog.setIcon(android.R.drawable.ic_dialog_info);
		dialog.setTitle("weibo");
		dialog.setMessage(message);
		dialog.setPositiveButton("OK", new OnClickListener() {
			@Override
			public void onClick(DialogInterface dialog, int which) {
					
					switch (action)
					{
					case Constants.task.GET_RUEST_TOKEN:
						Activity activity = (Activity) context;
						activity.finish();
						break;

					default:
						break;
					}
			}
		});
		dialog.setCancelable(false);
		dialog.show();
	}

	public static void TwoButtonShowMessageDialog(Context context,
			int resId, OnClickListener leftListener,
			OnClickListener rightListener) {
		String message = context.getResources().getString(resId);
		if (message == null || message.equals("")) {
			return;
		}
		AlertDialog.Builder dialog = new Builder(context);
		dialog.setMessage(message);
		dialog.setPositiveButton("YES", leftListener);
		dialog.setNegativeButton("NO", rightListener);
		dialog.setCancelable(false);
		dialog.show();
	}
	
	public static void ToastShow(Context context, String message)
	{
		Toast.makeText(context, message, Toast.LENGTH_SHORT).show();
	}
}
